home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1994 June / PC Plus Super CD coverdisc Issue 93 June 1994.iso / suprdisk / button / frmnew.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-04-01  |  7.4 KB  |  250 lines

  1. VERSION 2.00
  2. Begin Form frmNew 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "New Button"
  6.    ClientHeight    =   3225
  7.    ClientLeft      =   2025
  8.    ClientTop       =   3105
  9.    ClientWidth     =   4455
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   3630
  13.    Left            =   1965
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   3225
  18.    ScaleWidth      =   4455
  19.    Top             =   2760
  20.    Width           =   4575
  21.    Begin HScrollBar hsrDown 
  22.       Height          =   285
  23.       Left            =   3375
  24.       TabIndex        =   5
  25.       Top             =   1350
  26.       Width           =   390
  27.    End
  28.    Begin HScrollBar hsrAcross 
  29.       Height          =   285
  30.       Left            =   3375
  31.       TabIndex        =   4
  32.       Top             =   990
  33.       Width           =   390
  34.    End
  35.    Begin TextBox tbxAcross 
  36.       Height          =   285
  37.       Left            =   2850
  38.       MaxLength       =   2
  39.       TabIndex        =   0
  40.       Top             =   990
  41.       Width           =   465
  42.    End
  43.    Begin TextBox tbxDown 
  44.       Height          =   285
  45.       Left            =   2850
  46.       MaxLength       =   2
  47.       TabIndex        =   1
  48.       Top             =   1350
  49.       Width           =   465
  50.    End
  51.    Begin CommandButton cmdOK 
  52.       Caption         =   "OK"
  53.       Height          =   420
  54.       Left            =   975
  55.       TabIndex        =   2
  56.       Top             =   1935
  57.       Width           =   915
  58.    End
  59.    Begin CommandButton cmdCancel 
  60.       Cancel          =   -1  'True
  61.       Caption         =   "Cancel"
  62.       Height          =   420
  63.       Left            =   2250
  64.       TabIndex        =   3
  65.       Top             =   1935
  66.       Width           =   915
  67.    End
  68.    Begin Label lblMax 
  69.       Alignment       =   2  'Center
  70.       BackStyle       =   0  'Transparent
  71.       Caption         =   "Maximise the window to increase the maximum sizes"
  72.       Height          =   465
  73.       Left            =   900
  74.       TabIndex        =   12
  75.       Top             =   2520
  76.       Visible         =   0   'False
  77.       Width           =   2415
  78.    End
  79.    Begin Label Label2 
  80.       BackStyle       =   0  'Transparent
  81.       Caption         =   "(Minimum = 11 pixels). F1 for Help"
  82.       FontBold        =   -1  'True
  83.       FontItalic      =   0   'False
  84.       FontName        =   "MS Sans Serif"
  85.       FontSize        =   8.25
  86.       FontStrikethru  =   0   'False
  87.       FontUnderline   =   -1  'True
  88.       ForeColor       =   &H000000C0&
  89.       Height          =   195
  90.       Left            =   750
  91.       TabIndex        =   11
  92.       Top             =   585
  93.       Width           =   2940
  94.    End
  95.    Begin Label Label1 
  96.       BackStyle       =   0  'Transparent
  97.       Caption         =   "Please enter the button dimensions in Pixels"
  98.       FontBold        =   -1  'True
  99.       FontItalic      =   0   'False
  100.       FontName        =   "MS Sans Serif"
  101.       FontSize        =   8.25
  102.       FontStrikethru  =   0   'False
  103.       FontUnderline   =   -1  'True
  104.       ForeColor       =   &H000000C0&
  105.       Height          =   240
  106.       Left            =   300
  107.       TabIndex        =   10
  108.       Top             =   270
  109.       Width           =   3840
  110.    End
  111.    Begin Label lblMaxHeight 
  112.       BackStyle       =   0  'Transparent
  113.       Caption         =   "lblMaxY"
  114.       Height          =   240
  115.       Left            =   2025
  116.       TabIndex        =   9
  117.       Top             =   1395
  118.       Width           =   615
  119.    End
  120.    Begin Label lblMaxAcross 
  121.       BackStyle       =   0  'Transparent
  122.       Caption         =   "lblMaxX"
  123.       Height          =   240
  124.       Left            =   2025
  125.       TabIndex        =   8
  126.       Top             =   1035
  127.       Width           =   690
  128.    End
  129.    Begin Label lblAcross 
  130.       BackStyle       =   0  'Transparent
  131.       Caption         =   "Across (Max ="
  132.       Height          =   285
  133.       Left            =   750
  134.       TabIndex        =   7
  135.       Top             =   1035
  136.       Width           =   1290
  137.    End
  138.    Begin Label lblDown 
  139.       BackStyle       =   0  'Transparent
  140.       Caption         =   "Down  (Max ="
  141.       Height          =   285
  142.       Left            =   750
  143.       TabIndex        =   6
  144.       Top             =   1395
  145.       Width           =   1215
  146.    End
  147. Option Explicit
  148. Dim MaxWidth As Integer
  149. Dim MaxHeight As Integer
  150. Sub cmdCancel_Click ()
  151.     frmNew.Tag = ""
  152.     frmNew.Hide
  153. End Sub
  154. Sub cmdOK_Click ()
  155.     Dim Msg As String
  156.     Dim WhichLabel As Integer
  157.     On Error GoTo TooBig
  158.     If Val(tbxAcross) < 11 Then Error 32765
  159.     If Val(tbxDown) < 11 Then Error 32764
  160.     If tbxAcross > MaxWidth Then Error 32767
  161.     If tbxDown > MaxHeight Then Error 32766
  162.     BitMap.ButtonWidth = Val(frmNew!tbxAcross)
  163.     BitMap.ButtonHeight = Val(frmNew!tbxDown)
  164.     'Start a new master bitmap
  165.     BitMap.Position = 0
  166.     frmBitMap!picBitMap.Cls
  167.     frmNew.Tag = "OK"
  168.     frmNew.Hide
  169. Exit Sub
  170. TooBig:
  171.     Select Case Err
  172.         Case 32767
  173.             Msg = "TOO WIDE! Max width is " & Str$(MaxWidth)
  174.             WhichLabel = 1
  175.         Case 32766
  176.             Msg = "TOO HIGH! Max height is " & Str$(MaxHeight)
  177.             WhichLabel = 2
  178.         Case 32765
  179.             Msg = "That's not a valid entry"
  180.             WhichLabel = 1
  181.         Case 32764
  182.             Msg = "That's not a valid entry"
  183.             WhichLabel = 2
  184.         Case Else
  185.             MsgBox "Unexpected error"
  186.     End Select
  187.     If Err > 32765 And frmButton.WindowState = 0 Then Msg = Msg & CR & "Try maximising the window"
  188.     MsgBox Msg, 0, "Buttons"
  189.     If WhichLabel = 1 Then
  190.         tbxAcross.SetFocus
  191.     Else
  192.         tbxDown.SetFocus
  193.     End If
  194.     Exit Sub
  195.     Resume Next
  196. End Sub
  197. Sub Form_Activate ()
  198.     Dim Subtract As Integer
  199.     Select Case frmButton.WindowState
  200.         Case 0
  201.             lblMax.Visible = True
  202.         Case Else
  203.             lblMax.Visible = False
  204.     End Select
  205.     Subtract = frmButton!picTools.Height + frmButton!lblButton(0).Height + 6
  206.     MaxHeight = (frmButton.ScaleHeight - Subtract) \ 9
  207.     MaxWidth = (frmButton.ScaleWidth \ 9) - 1
  208.     hsrAcross.Min = 11
  209.     hsrDown.Min = 11
  210.     hsrAcross.Max = MaxWidth
  211.     hsrDown.Max = MaxHeight
  212.     lblMaxAcross = Format$(MaxWidth) & ")"
  213.     lblMaxHeight = Format$(MaxHeight) & ")"
  214.     tbxAcross.SetFocus
  215.     HelpItem = 9
  216. End Sub
  217. Sub Form_KeyDown (Keycode As Integer, Shift As Integer)
  218.     If Keycode = &H70 Then Cheap_Help Format$(HelpItem)
  219. End Sub
  220. Sub Form_Load ()
  221.     Position_Form frmNew
  222.     KeyPreview = True
  223.     hsrAcross = 25
  224.     hsrDown = 25
  225. End Sub
  226. '   Select the text in the textbox that has got the focus
  227. '   - Called from the textbox's GotFocus event
  228. Sub Highlight (ctr As TextBox)
  229.     ctr.SelStart = 0
  230.     ctr.SelLength = Len(ctr)
  231. End Sub
  232. Sub hsrAcross_Change ()
  233.     tbxAcross = hsrAcross
  234. End Sub
  235. Sub hsrDown_Change ()
  236.     tbxDown = hsrDown
  237. End Sub
  238. Sub tbxAcross_GotFocus ()
  239.     Highlight tbxAcross
  240. End Sub
  241. Sub tbxAcross_KeyPress (Keyascii As Integer)
  242.     If Keyascii = 13 Then Keyascii = 0: tbxDown.SetFocus
  243. End Sub
  244. Sub tbxDown_GotFocus ()
  245.     Highlight tbxDown
  246. End Sub
  247. Sub tbxDown_KeyPress (Keyascii As Integer)
  248.     If Keyascii = 13 Then Keyascii = 0: cmdOk.SetFocus
  249. End Sub
  250.